
#ifndef __BROKER_5_CLIENT_H
#define __BROKER_5_CLIENT_H

#include "TCPClient.h"
#include "BrokerMessage.h"
#include "../db/KeyDB.h"

/** A TCP client for the broker v5 server. */
class Broker5Client : public TCPClient
{
   public:
      static int exchangeMessage(BrokerMessage &bmsg, apr_pool_t *imp, int *cancelflag, const char *thostname, int tportno, KeyDB &tkeydb, int ttimeout);
      Broker5Client(const char *ihostname, int iportno, apr_pool_t *imp) : TCPClient(ihostname, iportno, imp) {}
      ~Broker5Client() {}
      BrokerMessage *exchangeMessage(BrokerMessage &msg, KeyDB &kdb);
      static void *exchangeMessageThread(apr_thread_t *tthread, void *args);
      APRFuture<BrokerMessage *> *exchangeMessageFuture(BrokerMessage &msg, KeyDB &kdb);
      int sendMessage(BrokerMessage &msg, KeyDB &kdb);
      int receiveMessage(BrokerMessage &msg, KeyDB &kdb);
};

#endif
